from abc import abstractmethod, ABCMeta


class IScan(metaclass=ABCMeta):
    @property
    @abstractmethod
    def inputs(self):
        pass

    @property
    @abstractmethod
    def outputs(self):
        pass

    def get_fields(self, obj:object, flat_field:str) -> str:
        fields = flat_field.split('.')

        try:
            current_obj = obj
            for field in fields:
                current_obj = current_obj[field] if current_obj[field] else ''

            if isinstance(current_obj, int):
                current_obj = str(current_obj)

            if isinstance(current_obj, list):
                current_obj = ','.join([str(i) for i in current_obj])

            return current_obj

        except Exception as e:
            return ''
